import { computed, reactive, ref } from "vue";
import { tableColumnMap } from "../data";

export default function InitHook() {
  const tableRef = ref<any>(null);
  const activeKey = ref<string>("1");
  const pageStat = ref<Base.GeneraDataType>({
    1: 0,
    2: 0,
    3: 0
  });
  const searchForm = reactive<ReleaseCargo.SearchForm>({
    beforePageNum: 0,
    applyNoList: "",
    customerIdList: [],
    companyIdList: [],
    bizIdList: [],
    followIdList: [],
    statusList: [],

    pageNum: 1,
    pageSize: 100,
    total: 0
  });
  const tableData = ref<Array<ReleaseCargo.ListRows>>([]);
  const dialogOpts = reactive<Base.DialogOpts>({
    title: "",
    width: "520px",
    component: "",
    visible: false,
    type: 1,
    passData: {}
  });
  const drawerOpts = reactive<Base.DrawerOpts>({
    title: "",
    width: "520px",
    component: "",
    visible: false,
    type: 1,
    passData: {}
  });
  const tableColumn = computed<Array<SuperTable.NestTableColumnItem | SuperTable.TableCoulmnItem>>(() => {
    return tableColumnMap[activeKey.value];
  });
  const visible = ref<boolean>(false);
  // const setVisible = (index: number, row: any): void => {
  //   row[index].isVisible = true;
  // };
  // const onVisibleChange = (row: any, index: number, v: boolean) => {
  //   row[index].isVisible = v;
  // };

  return {
    searchForm,
    tableData,
    tableRef,
    activeKey,
    pageStat,
    dialogOpts,
    drawerOpts,
    tableColumn,
    visible
    // setVisible,
    // onVisibleChange
  };
}
